package com.yuxinmuyu.sports_management.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yuxinmuyu.sports_management.bean.entiy.SysUsers;
import com.yuxinmuyu.sports_management.exception.BusinessException;
import com.yuxinmuyu.sports_management.mapper.UserMapper;
import com.yuxinmuyu.sports_management.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author 张钦栩
 * @Email 1784746527@qq.com
 * @Create 2024-06-22
 * @Description
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public SysUsers getByUserName(String username) {
        return userMapper.selectOne(Wrappers.<SysUsers>lambdaQuery().
                eq(SysUsers::getUserName,username));
    }

    @Override
    public SysUsers getByID(String userID) {
        return userMapper.selectById(userID);
    }

    @Override
    public void update(SysUsers users) {
        int n=userMapper.updateById(users);
        if (n==0){
            throw new BusinessException("修改密码失败！");
        }
    }


}
